package com.param_validate_demo.annotation;

import com.param_validate_demo.validator.AgeValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

@Documented
@Constraint(validatedBy = AgeValidator.class)
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface AgeValidate {
    /**
     * 必要参数，否则报错
     */
    String message() default "男性年龄必须大于等于22，女性年龄必须大于等于20";

    /**
     * 必要参数，否则报错
     * javax.validation.ConstraintDefinitionException: HV000074: com.param_validate_demo.annotation.EnumValidate contains Constraint annotation, but does not contain a groups parameter.
     */
    Class<?>[] groups() default { };

    /**
     * 必要参数，否则报错
     */
    Class<? extends Payload>[] payload() default {};
}
